package com.kylin.test;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.ListView;

import com.kylin.test.entity.ContactsEntity;
import com.kylin.test.utils.ContactsUtils;

import java.util.ArrayList;

public class MainActivity extends Activity {
    ArrayList<ContactsEntity> list  = new ArrayList<>();
    private Context mContext;
    private ListViewAdapter adapter;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        mContext = this;


        ListView listView = (ListView) findViewById(R.id.listView);
        adapter = new ListViewAdapter(mContext);
        listView.setAdapter(adapter);


        Button button = (Button) findViewById(R.id.bt_test);
        button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Log.e("onClick","onClick");
                list = ContactsUtils.getAllContacts(MainActivity.this);
                adapter.setData(list);
            }
        });


    }
}
